package com.cardone.platform.common.service;

import java.util.Map;

import lombok.Getter;
import lombok.Setter;

import org.springframework.transaction.annotation.Transactional;

import com.cardone.context.ContextHolder;
import com.cardone.context.function.Execution1Function;
import com.cardone.platform.common.dao.EntityCodeDao;

/**
 * 实体编号服务
 *
 * @author yaohaitao
 *
 */
@Getter
@Setter
@Transactional(readOnly = true)
public class EntityCodeDefaultService implements EntityCodeService {

	@Override
	@Transactional
	public String generateCode(final String id, final String typeCode) {
		return ContextHolder.getBean(EntityCodeDao.class).generateCode(id, typeCode, null, null);
	}

	@Override
	@Transactional
	public String generateCode(final String id, final String typeCode, final Execution1Function<String, String> function, final Map<String, Object> parameters) {
		return ContextHolder.getBean(EntityCodeDao.class).generateCode(id, typeCode, function, parameters);
	}

	@Override
	@Transactional
	public String generateCode(final String id, final String typeCode, final Map<String, Object> parameters) {
		return ContextHolder.getBean(EntityCodeDao.class).generateCode(id, typeCode, null, parameters);
	}
}